<template>
  <div class="container">
    <div class="div_block">
      <div class="form_block">
        <el-form>
          <el-form-item style="margin-top: 50px">
            <el-input placeholder="注册用户名" v-model="form.username"></el-input>
          </el-form-item>
          <el-form-item>
            <el-input placeholder="设置密码" v-model="form.password" type="password"></el-input>
          </el-form-item>
          <el-form-item class="email_block">
            <el-input placeholder="邮箱" v-model="form.email"></el-input>
<!--            <el-button type="info">验证</el-button>-->
          </el-form-item>
          <el-form-item class="confirm_block">
<!--            <el-input placeholder="验证码" v-model="form.confirm"></el-input>-->
            <el-button type="primary" plain round @click="regist">注册</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "RegistBlock",
  data(){
    return {
      form:{
        username:"",
        password:"",
        email:""
      },
    }
  },
  methods:{
    async regist(){
      console.log(this.form)
      //调用接口，注册
      this.form.password = this.$md5(this.form.password);
      const{data:res} = await this.$http.post("http://120.46.132.13:8081/register",this.form);

      if(res.code===0){
        this.$notify.success(res.message);
      }else{
        this.$notify.error(res.message);
      }

      this.$router.push('/sign/login')
    }
  }
}
</script>

<style scoped>
  .container{
    height: 100%;
    width: 100%;
  }

  .div_block{
    width: 80%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
  }

  .form_block{

  }

  .email_block .el-input{
    width: 200px;
    display: inline-block
  }

  .email_block .el-button{
    display: inline-block;
    margin-left: 7px;
    float: right
  }

  .confirm_block .el-input{
    /*width: 100px*/
    width: 100%;
  }
  .confirm_block .el-button{
    /*width: 180px;*/
    width: 100%;
    margin-bottom: 30px;
  }
</style>
